package org.springframework.validation.executors.impl;

import org.springframework.validation.executors.RuleExecutor;
import org.springframework.validation.util.ValidationRulesUtils;

public class MatchesRuleExecutor implements RuleExecutor {

	@Override
	public boolean validate(Object model, Object argument) throws Exception {
		if (ValidationRulesUtils.isEmpty(model) && ValidationRulesUtils.isEmpty(argument)) {
			return true;
		} else if (ValidationRulesUtils.isEmpty(model) || ValidationRulesUtils.isEmpty(argument)) {
			return false;
		} else if (model == argument || model.equals(argument) 
			|| String.valueOf(model).equals(String.valueOf(argument))) {
			return true;
		} else {
			return false;
		}
	}
		

}
